/**
* @file executor_manager.h
*
* Copyright (c) Huawei Technologies Co., Ltd. 2021-2022. All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/


#ifndef EXECUTOR_MANAGER_H_
#define EXECUTOR_MANAGER_H_

#include <unordered_map>
#include <memory>
#include <atomic>
#include <mutex>
#include "framework/runtime/model_v2_executor.h"
#include "acl/acl_base.h"

namespace acl {
class ExecutorManager {
public:
    ~ExecutorManager() = default;
    static ExecutorManager &GetInstance()
    {
        static ExecutorManager instance;
        return instance;
    }
    bool IsRuntimeV2Enable() const
    {
        return enableRuntimeV2_;
    }
    void AddExecutor(uint32_t &modelId, std::unique_ptr<gert::ModelV2Executor> executor);
    std::shared_ptr<gert::ModelV2Executor> GetExecutor(const uint32_t modelId);
    aclError DeleteExecutor(const uint32_t modelId);
    void GetRuntimeV2Env();
private:
    ExecutorManager() = default;

private:
    std::unordered_map<uint32_t, std::shared_ptr<gert::ModelV2Executor>> executorMap_;
    std::atomic_uint32_t modelIdGenerator_ {0U};
    bool enableRuntimeV2_ = false;
    std::mutex mutex_;
};
}
#endif
